package com.activeMq.entity;

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

public class Producer {
    public static void main(String[] args) throws JMSException {
        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://127.0.0.1:61616");
        factory.setTrustAllPackages(true);
        Connection connection = factory.createConnection();
        connection.start();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Queue queue = session.createQueue("tx_queue");
        MessageProducer producer = session.createProducer(queue);

        //TextMessage message = session.createTextMessage("你好吗" + i);
        ObjectMessage message=session.createObjectMessage();
        Person person=new Person();
        person.setAge(1);
        person.setName("hao");
        message.setObject(person);
        producer.send(message);

        producer.close();
        session.close();
        connection.close();
    }
}
